package com.welsy.usermgt.business
{
	import com.welsy.usermgt.vo.SearchVO;
	import mx.controls.Alert;
	import com.welsy.usermgt.vo.UserVO;
	import com.adobe.cairngorm.business.ServiceLocator;
	import mx.rpc.soap.mxml.WebService;
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;	
	
	public class SearchDelegate 
	{
		private var responder : IResponder;
		private var service : Object;
		
		public function SearchDelegate( responder : IResponder ) {
			//Recorded in Services.mxml
			this.responder = responder;
			this.service = ServiceLocator.getInstance().getWebService("UserMgtService") as WebService;
		}		
		
		public function getServerSrcResult(searchVO : SearchVO):void {
			//Create the request
			var op : AbstractOperation = service.getOperation("SearchUsers");
			op.arguments.SearchUsersRequest.SubSystemId = searchVO.SubSystemId;
			op.arguments.SearchUsersRequest.SearchDataType = searchVO.SearchDataType;
			op.arguments.SearchUsersRequest.SearchCriteria.FirstName = searchVO.FirstName;
			op.arguments.SearchUsersRequest.SearchCriteria.LastName = searchVO.LastName;
			op.arguments.SearchUsersRequest.SearchCriteria.Login = searchVO.Login;
			op.arguments.SearchUsersRequest.SearchCriteria.Roles = searchVO.Roles;
							
			var token : AsyncToken = service.SearchUsers();
			token.addResponder(responder);
		}		
		
	}
}